<?php
error_reporting(E_ALL);
define('THEME', 'bootstrap');
require_once 'core/init.php';
// Config Initialize
$config = initAppConfig();
Registry::getInstance()->set('config', $config);
// Router
$router = new Router();
Registry::getInstance()->set('router', $router);
//Included Files
Registry::getInstance()->set('includedfiles', array());
// Loader
$loader = new Loader();

Registry::getInstance()->set('load', $loader);

// Database 
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
Registry::getInstance()->set('db', $db);
// Front Controller 

$controller = new Front();
// Request
$request = new Request();
Registry::getInstance()->set('request', $request);
// Repsonse
$response = new Response();
Registry::getInstance()->set('response', $response);
//Theme Unit
$themeUnit = new ThemeUnit("standart");
Registry::getInstance()->set('themeunit', $themeUnit);
////// Feed Observer
//$FeedObserver = new FeedObserver();
//Registry::getInstance()->set('feedobserver', $FeedObserver);
////// Messages Observer
$MessagesObserver = new MessagesObserver();
Registry::getInstance()->set('messagesobserver', $MessagesObserver);
Event::addObserver($MessagesObserver);

$form_manager = new FormManager();
Registry::getInstance()->set('form_manager', $form_manager);

// Hook
$hook = new Hook();
Registry::getInstance()->set('hook', $hook);

$hook->invokeAll('beforeinit');
$request_context = $controller->handleRequest($router->getAction(@$_GET['rewritequery']));
$hook->invokeAll('afterinit');
//render and out
$themeUnit->renderPage($request_context->getCurrentAction());
?>


